import Vue from "vue";
import VueRouter from "vue-router";
import Login from "../views/Login.vue";
//import Register from "../views/Register.vue";
import Index from "../views/Index.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "login",
    redirect: "/login"
  },
  {
    path: "/login",
    name: "login",
    component: Login
  },
  {
    path: "/register",
    name: "register",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ "../views/Register.vue")
  },
  {
    path: "/index",
    name: "index",
    component: () => import("../views/Index.vue")
  },
  {
    path: "/botnav",
    name: "botnav",
    component: () => import("../views/Botnav.vue"),
    children:[
      //嵌套路由的路径不用：
      {
        path: "/",
        name: "index",
        component: Index
      },
      {
        path: "index",
        name: "index",
        component: () => import("../views/Index.vue")
      },
      {
        path: "list",
        name: "list",
        component: () => import("../views/List.vue")
      },
      {
        path: "search",
        name: "search",
        component: () => import("../views/Search.vue")
      },
      {
        path: "cart",
        name: "cart",
        component: () => import("../views/Cart.vue")
      },
      {
        path: "mine",
        name: "mine",
        component: () => import("../views/Mine.vue")
      }
    ]
  }
];

const router = new VueRouter({
  routes
});

export default router;
